Judge an element in a set or not

#Judge an element in a set or not
print("Enter the element to be judged:")
a = input()
print("Enter the set to be judged:")
s = set(input().split())
if a in s:
    print("The element %s is in the set %s" % (a,s))
else:
    print("The element %s is not in the set %s" % (a,s))

Judge if a set is a subset of another set

#Judge if a set is a subset of another set
print("Input a set:")
a=set(input().split())
print("Input another set")
b=set(input().split())
if a.issubset(b):
    print("The set %s is the subset of the set %s" % (a,b))
elif b.issubset(a):
    print("The set %s is the subset of the set %s" % (b,a))
else:
    print("There is no subset relationship between the set %s and the set %s" % (a,b))

Judge if a set is a proper subset of another set

#Judge if a set is a proper subset of another set
print("Input a set:")
a=set(input().split())
print("Input another set")
b=set(input().split())
if len(a)!=len(b) and a.issubset(b):
    print("The set %s is the proper subset of the set %s" % (a,b))
elif len(a)!=len(b) and b.issubset(a):
    print("The set %s is the proper subset of the set %s" % (b,a))
else:
    print("There is no proper subset relationship between the set %s and the set %s" % (a,b))

Judge if two sets are equal

#Judge if two sets are equal
print("Input a set:")
a=set(input().split())
print("Input another set")
b=set(input().split())
if a==b:
    print("The set %s is equal to the set %s" % (a,b))
else:
    print("The set %s is not equal to the set %s" % (a,b))

Judge a collection as an empty set

#Judge a collection as an empty set
print("Input a set to be judged:")
a=set(input().split())
if a:
    print("The set %s is not an empty set" % (a))
else:
    print("The set is an empty set")

Reference artical:
https://blog.csdn.net/u013247765/article/details/79052257

Calculate the number of elements in a set

#Calculate the number of elements in a set
print("Input the set to be calculated:")
a=set(input().split())
print("The number of elements in the set %s is %d" % (a,len(a)))

List a set of power set elements and return the number of elements

#List a set of power set elements and return the number of elements
def powerset(items):  
    N = len(items)  
    sall=[]
    for i in range(2**N):
        powers = []  
        for j in range(N):  
            if(i >> j ) % 2 == 1:  #For the i-th bit of the binary of x, if it is 1, this subset contains the ith element of s, otherwise it is not included.
                powers.append(items[j])
        sall.append(powers)
    return sall
print("Input a set:")
a=set(input().split())
ans=powerset(list(a))
print("The power set of the set %s are:" % (a))
print(ans)
print("The number of elements is %d" % (len(ans)))

Reference artical:
https://blog.csdn.net/beyondwdq/article/details/5540386
https://blog.csdn.net/luoganttcc/article/details/80785149

Find the union of two sets

#Find the union of two sets
print("Input a set:")
a=set(input().split())
print("Input another set:")
b=set(input().split())
print("the union of set %s and set %s is %s" % (a,b,a|b))

Judge if the intersection of two sets is an empty set

#Judge if the intersection of two sets is an empty set
print("Input a set:")
a=set(input().split())
print("Input another set:")
b=set(input().split())
ans=a&b
if ans:
    print("The intersection of set %s and set %s is not an empty set" % (a,b))
else:
    print("The intersection of set %s and set %s is an empty set" % (a,b))

Find the intersection of two sets

#Find the intersection of two sets
print("Input a set:")
a=set(input().split())
print("Input another set:")
b=set(input().split())
print("The intersection of set %s and set %s is %s" % (a,b,a&b))

Find the relative complement of two sets

#Find the relative complement of two sets
print("Input a set:")
a=set(input().split())
print("Input another set:")
b=set(input().split())
print("The relative complement of set %s and %s is %s" % (a,b,a-b))
print("The relative complement of set %s and %s is %s" % (b,a,b-a))

Something about relative complement:
baike.baidu
Wikipedia

Find the symmetric difference set of two sets

#Find the symmetric difference set of two sets
print("Input a set:")
a=set(input().split())
print("Input another set:")
b=set(input().split())
print("The symmetric difference set of set %s and set %s is %s" % (a,b,(a|b)-(a&b)))

Something about symmetric difference set:
baike.baidu
Wikipedia